package org.example.route.mapper;

import org.apache.ibatis.annotations.*;
import org.example.route.model.pojo.Seat;

import java.util.List;

@Mapper
public interface SeatMapper {

    @Insert("insert into seat (carriage_id, status, seat_number, the_row) VALUES (#{carriageId}" +
            ",#{status},#{seatNumber},#{theRow})")
    void add(Seat seat);

    @Update("update seat set status = 0 where id = #{seatId}")
    void beOccupied(Long seatId);

    @Select("select carriage_id from seat where id = #{seatId}")
    Long getCarriageIdById(Long seatId);

    @Select("select the_row from seat where id = #{seatId}")
    Long getTheRowById(Long seatId);

    @Select("select seat_number from seat where id = #{seatId}")
    Long getSeatNumberById(Long seatId);

    @Select("select carriage_number from carriage where id = #{id}")
    Long getCarriageNumberById(Long Id);

    @Update("update seat set status = 1 where id = #{seatId}")
    void beReleased(Long seatId);

    @Select("select * from seat where carriage_id = #{carriageId}")
    List<Seat> listByCarriageId(Long carriageId);


    void deleteByCarriageIds(List<Long> carriageIds);
}
